<template>
  <div>
    <render-table
      ref="table"
      :apiUrl="supplierAllQuotation"
      :tableColumn="tableColumn"
      :otherConfig="otherConfig"
      :setupConfig="setupConfig"
      :searchReset="searchReset"
      :searchConfig="searchConfig"
    >
    <template v-slot:state="{ row }">
      <el-tag
          type="danger"
          v-if="row.state === '0'"
          style="margin-left: 10px"
          >已报价</el-tag
        >
        <el-tag
          type="danger"
          v-if="row.state === '1'"
          style="margin-left: 10px"
          >报价已截止</el-tag
        >
        <el-tag
          type="primary"
          v-else-if="row.state === '2'"
          style="margin-left: 10px"
          >送货中</el-tag
        >
        <el-tag
          type="success"
          v-else-if="row.state === '3'"
          style="margin-left: 10px"
          >订单完成</el-tag
        >
        <el-tag
          type="success"
          v-else-if="row.state === '4'"
          style="margin-left: 10px"
          >评价完成</el-tag
        >
      </template>
      <template v-slot:photo="{row}">
        <el-image 
    style="width: 100px; height: 100px"
    :src="baseUrl + row.photo" 
    :preview-src-list="srcList"
    @click="vbs(baseUrl + row.photo)">
  </el-image>
      </template>
    </render-table>
  </div>
</template>
      
      <script>
import { supplierAllQuotation,supplierDelOrder } from "@/api/supplier/api";

export default {
  props: {
    searchReset: {
      // 搜索条件默认值重置值
      type: Object,
    },
  },
  name: "quote-manager",
  data() {
    return {
      srcList:[],
      baseUrl: process.env.VUE_APP_BASE_API,
      searchConfig: [
        {
          type: "input",
          key: "orderName",
          placeholder: "请输入订单名称",
        },
        {
          type: "input",
          key: "orderId",
          placeholder: "请输入订单编号",
        },
      ],
      searchReset: {
        orderName: "",
        orderId:''
      },
      setupConfig: {
        width:0
        // del: true,
      },
      dict: {},
      otherConfig: {
        list: "rows",
      },
      supplierAllQuotation,
      tableColumn: [
        { prop: "type", label: "订单类型" },
        { prop: "orderName", label: "订单名称" },
        { prop: "orderId", label: "订单编号" },
        { prop: "purchaseName", label: "采购员" },
        { prop: "countPrice", label: "总价" },
        { prop: "state", label: "状态" , slot: true ,width:120},
        { prop: "endTime", label: "截止时间" },
        { prop: "photo", label: "附件", slot: true },
      ],
    };
  },
  created() {},
  methods: {
    vbs(val){
      this.srcList = []
      this.srcList.push(val)
    },
    del(row) {
      const data = {}
      data.orderId = row.orderId || this.ids;
      data.type = row.type 
      this.$modal
        .confirm(
          '是否确认撤销订单名称为"' + row.orderName + '"的报价单？'
        )
        .then(function () {
          return supplierDelOrder(data);
        })
        .then(() => {
          this.$refs.table.getData();
          this.$modal.msgSuccess("撤销成功");
        })
        .catch(() => {});
    },
  },
};
</script>
      